package com.sl.mes.app.controller.bd;


import com.sl.mes.app.dao.bd.AggBdMaterialVo;
import com.sl.mes.app.service.bd.BdMaterialVService;
import com.sl.mes.core.util.JacksonUtil;
import com.sl.mes.core.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/mes/bdmaterial")
@Validated
public class BdMaterialController {

    @Autowired
    private BdMaterialVService bdMaterialVService;

    @GetMapping("getAggBdMaterailVoById")
    public Object getAggBdMaterailVoById(@RequestBody String body, HttpServletRequest request){
        String pkSource = JacksonUtil.parseString(body, "pk_source");
        Map<Object, Object> result = new HashMap<Object, Object>();
        AggBdMaterialVo aggBdMaterialVo =bdMaterialVService.getBdMaterialById(pkSource);
        result.put("aggBdMaterialVo",aggBdMaterialVo);
        return ResponseUtil.ok(result);
    }
}
